from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models


class Focus(models.Model):
    title = models.CharField(verbose_name="标题", max_length=20)
    link_to = models.URLField(verbose_name="链接")
    thumbnail = models.URLField(verbose_name="图")
    pub_time = models.DateTimeField(verbose_name='开始时间')
    end_time = models.DateTimeField(verbose_name='结束时间')
    priority = models.IntegerField(verbose_name='优先级', default=99, validators=[
        MaxValueValidator(100),  # 限定存储的最大值为100
        MinValueValidator(1)  # 限定存储的最小值为1
    ])

    class Meta:
        db_table = 'focus'
        verbose_name = '焦点图'
        verbose_name_plural = verbose_name
